package MapReduce.writableComperable;

import MapReduce.PartitionerAndWriteComparable.ProvincePartitioner2;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class FlowMain {
    public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {

        //1. 获取job对象
        Job job = new Job(new Configuration(), "Writable job");

        //2. 设置jar
        job.setJarByClass(FlowMain.class);

        //3. 关联Mapper和Reducer
        job.setMapperClass(FlowMapper.class);
        job.setReducerClass(FlowReducer.class);

        //4. 设置mapper输出的Key value类型  ---注意此处
        job.setMapOutputKeyClass(FlowBean.class);
        job.setMapOutputValueClass(Text.class);

        //5. 设置最终输出的Key和Value类型
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(FlowBean.class);

        //6. 设置数据的输入和输出路径
        FileInputFormat.addInputPath(job, new Path("D:\\中国科学院大学硕士\\学习类文件夹\\BigDataDev\\Output\\output1\\part-r-00000"));
        FileOutputFormat.setOutputPath(job, new Path("D:\\中国科学院大学硕士\\学习类文件夹\\BigDataDev\\Output\\output5"));

        //7. 提交job
        boolean flag = job.waitForCompletion(true);
        System.exit(flag ? 0 : 1);
    }
}
